cmake_minimum_required(VERSION 3.16)

project(myRiscPjt LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/)

add_compile_definitions(
  -DROOT_PATH="${CMAKE_CURRENT_SOURCE_DIR}"
)

add_executable(myRiscPjt
  src/main.cpp

  #plat
  src/plat/plat.h

  #test
  src/test/instr_test.h

  #core
  src/core/riscv.cpp
  src/core/riscv.h
  src/core/types.h
  src/core/instr.h

  #device
  src/device/mem.cpp
  src/device/mem.h
  src/device/device.cpp
  src/device/device.h
)

target_link_libraries(myRiscPjt Qt${QT_VERSION_MAJOR}::Core)

include(GNUInstallDirs)
install(TARGETS myRiscPjt
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
